package top.zhangjianyong.blog.entity.po;

import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import top.zhangjianyong.blog.record.UserAgentRecord;

/**
 * UserAgent 信息实体类
 * 用于缓存和记录用户访问时的 User-Agent 解析信息
 *
 * @author zhangjianyong
 * @since 2025/1/26
 */
@Getter
@Setter
@TableName("user_agent_info")
public class UserAgentInfo extends BaseEntity {

    /** 原始 User-Agent 字符串 */
    private String userAgent;

    /** 浏览器名称 */
    private String browserName;

    /** 浏览器版本 */
    private String browserVersion;

    /** 操作系统名称 */
    private String osName;

    /** 操作系统版本 */
    private String osVersion;

    /** 设备类型 */
    private String deviceType;

    /** 设备品牌 */
    private String deviceBrand;

    /** 设备型号 */
    private String deviceModel;

    public void setRecord(UserAgentRecord record) {
        this.browserName = record.browserName();
        this.browserVersion = record.browserVersion();
        this.osName = record.osName();
        this.osVersion = record.osVersion();
        this.deviceType = record.deviceType();
        this.deviceBrand = record.deviceBrand();
        this.deviceModel = record.deviceModel();
    }
}